import axios from '@/libs/api.request'

export const getTestsuiteNames = (val) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuite/names/',
    params: val,
    method: 'get'
  })
};

export const getTestsuites = (val) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuites/',
    params: val,
    method: 'get'
  })
};

export const getTestsuiteById = (id) => {
  return axios.request({
    url: `api/HttpAutoTestService/testsuites/${id}/`,
    method: 'get'
  })
};

export const createTestsuite = (testsuite) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuite/',
    data: testsuite,
    method: 'post'
  })
};

export const updateTestsuite = (testsuite) => {
  return axios.request({
    url: `api/HttpAutoTestService/testsuite/${testsuite.id}/`,
    data: testsuite,
    method: 'put'
  })
};

export const partialUpdateTestsuite = (testsuite) => {
  let id = testsuite.id;
  delete testsuite.id;
  return axios.request({
    url: `api/HttpAutoTestService/testsuite/${id}/`,
    data: testsuite,
    method: 'patch'
  })
};

export const batchDeleteTestsuite = (data) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuite/batch_delete/',
    method: 'delete',
    data: data
  })
};

export const batchExecTestsuite = (data) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuite/batch_exec/',
    method: 'post',
    data: data
  })
};

export const copyTestsuite = (data) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuite/copy/',
    method: 'post',
    data: data
  })
};

export const exportTestsuite = (data) => {
  return axios.request({
    url: 'api/HttpAutoTestService/testsuite/export/',
    method: 'post',
    data: data,
    responseType: 'arraybuffer'
  })
};
